package com.zahb.qadx.ui.adapter;



import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zahb.qadx.R;
import com.zahb.qadx.model.TrainInfoBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


public class TrainRecordAdapter extends BaseQuickAdapter<TrainInfoBean.ListEntity, BaseViewHolder> implements LoadMoreModule {
    public TrainRecordAdapter(int layoutResId, @Nullable List<TrainInfoBean.ListEntity> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, TrainInfoBean.ListEntity s) {

        baseViewHolder.setText(R.id.tvTime,s.getStartTime()+" 至 "+s.getEndTime())
                .setText(R.id.tvType,s.getCateName())
                .setText(R.id.tvCompany,s.getTrainingUnit())
                .setText(R.id.tvTimeLength, getScore(s.getLearnHours())+"")
                .setText(R.id.tvStatus,getCompleteStatus(s.getCompleteStatus()))
                .setText(R.id.tvProgress,getScore(s.getLearnProgress()*100)+"%")
                .setText(R.id.tvCertificate, getCertificateStatus(s.getIsAwardCertificate()));










    }
    public String getScore(double score){
        if(score == (int)score){
            return  ((int)score)+"";
        }else{
            return score+"";
        }
    }

    public String getCertificateStatus(int status){
        if(status==0){
            return "未颁发";
        }
        if(status==1){
            return "已颁发";
        }
        if(status==2){
            return "无证书";
        }
        return "";
    }

    public String getCompleteStatus(int status){
        if(status==0){
            return "进行中";
        }
        if(status==1){
            return "已完成";
        }
        if(status==2){
            return "已过期";
        }
        return "";
    }
}
